package Sort.selectSort;

/**
 * @program: jvm
 * @description
 * @author: tkk fendoukaoziji
 * @create: 2019-05-09 10:02
 **/
public class ArraySe1 {
    private long[] a;
    private  int nElems;

    public  ArraySe1(int max){
        a=new long[max];
        nElems=0;
    }
    public void insert(long value){
        a[nElems]=value;
        nElems++;
    }
    public void display(){
        for (int j = 0; j < nElems; j++) {
            System.out.print(a[j]+" ");
        }
        System.out.println(" ");
    }
    public void selectSort(){
        int out,in,min;
        for (out = 0; out < nElems - 1; out++) {
            min=out;
            for(in=out+1;in<nElems;in++){
                if(a[in]<a[min]){
                    min=in;
                }
            }//end for
            long temp=a[out];
            a[out]=a[min];
            a[min]=temp;
        }
    }

    private void swap(int out, int min) {
        long temp = a[out];
        a[out]=a[min];
        a[min]=temp;
    }
}














